package xp2p.global;

import java.util.HashMap;

public class MessageCache {
	public long jobId;
	private HashMap<Long, byte[]> incoming = new HashMap<Long, byte[]>();
	private long msgIdSeed = 0;
	private Object sync = new Object();

	public long putMessage(byte[] data) {
		synchronized (sync) {
			msgIdSeed++;
			incoming.put(msgIdSeed, data);
			return msgIdSeed;
		}
	}

	public byte[] getMesage(long id) {
		synchronized (sync) {
			return incoming.get(id);
		}
	}
}